package Algorithm.BitOperation.swordOffer2;

/**
 * 剑指 Offer 15. 二进制中1的个数 https://leetcode.cn/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/
 */
public class HammingWeight {

    public static void main(String[] args) {
        new HammingWeight().hammingWeight(-11);
    }
    public int hammingWeight(int n) {
        int count = 0;
        while(n != 0) {
            count += n & 1;
            n >>>= 1;
        }
        return count;
    }
}
